package org.zhxy.zhxy.controller.front;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zhxy.zhxy.utils.EmailUtils;
import org.zhxy.zhxy.utils.RandomUtils;
import org.zhxy.zhxy.utils.Result;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/email")
public class EmailController {
    @Resource
    private EmailUtils emailUtils;
    //发送邮件验证码
    @PostMapping("/send")
    public Result sendEmail(String email){
        if (email==null|| "".equals(email)){
            return Result.fail("邮箱不能为空");
        }
        String ranDomCode = RandomUtils.getRanDomCode();
        emailUtils.sendEmail(email,ranDomCode);
        return Result.success();
    }
}
